package com.demo.test.state.mode;

import com.demo.test.state.mode.iml.State;

public class CurrTime8 implements State {

    @Override
    public void handle(WorkContext workContext) {

        if(workContext.getCurrTime() <= 8){

            delay(workContext);

        }else{
            workContext.setState(new CurrTime9());
            workContext.work();
        }
    }


    private void delay(WorkContext workContext){
        if(workContext.getPersonState() == 1){
            System.out.println("哇！又迟到了");
        }else {
            notEat(workContext);
        }
    }

    private void notEat(WorkContext workContext){
        if(workContext.getPersonState() == 2){
            System.out.println("来不及吃饭了，我要赶紧上班了");
        }else {
            eat(workContext);
        }
    }

    private void eat(WorkContext workContext){
        if(workContext.getPersonState() == 3){
            System.out.println("睡好吃足，状态满满上班去");
        }else{
            working(workContext);
        }
    }

    private void working(WorkContext workContext){
        if(workContext.getPersonState() == 4){
            System.out.println("上班那么早，生产队的驴都没你这么辛苦。");
        }else{
            other();
        }
    }

    private void other(){
        System.out.println("未知状态，错误警告");
    }

}
